﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using AutoMapper;
using FazaDemo.PL.ViewModelEntities;

namespace FazaDemo.PL.Mapping
{
    public class CharEnumSelectListItemsConverter : ITypeConverter<char?,IEnumerable<SelectListItem>>
    {

        private ICharEnumSelectItemsConvertWorker _convertWorker;


        public IEnumerable<SelectListItem> Convert(ResolutionContext context)
        {
            Contract.Requires(context != null);
            Contract.Requires(context.SourceValue != null);
            Contract.Requires(context.SourceValue is char?);
            ICharEnumConvertWorkerFactory factory = new CharEnumConvertWorkerFactory();
            _convertWorker = factory.Create(context.SourceValue as char?);
            return _convertWorker.Convert();
        }
    }
}
